<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>04_v-for与v-bind结合</title>

    <style>
      .index {
        color: coral;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <ul>
        <li
          :class="getClass()"
          v-for="(item,index) in names"
          v-on:click="clickText"
        >
          {{index}}-{{item}}
        </li>
      </ul>
    </div>
    <script src="../vue.js"></script>

    <script>
      const app = new Vue({
        el: "#app",
        data: {
          message: "hello",
          names: [
            "操作系统",
            "数据结构",
            "计算机组成原理",
            "算法",
            "计算机网络",
          ],
        },
        methods: {
          getClass: function () {
            return this.index;
          },
          clickText: function () {
            color: red;
          },
        },
      });
    </script>
  </body>
</html>
